package cn.wolfcode.luowowo.search.service.impl;

import cn.wolfcode.luowowo.search.domain.DestinationTemplate;
import cn.wolfcode.luowowo.search.domain.StrategyTemplate;
import cn.wolfcode.luowowo.search.qo.IndexSearchQo;
import cn.wolfcode.luowowo.search.repository.IDestinationTemplateRepository;
import cn.wolfcode.luowowo.search.repository.ITravelTemplateRepository;
import cn.wolfcode.luowowo.search.service.IDestinationTemplateService;
import cn.wolfcode.luowowo.search.service.ISearchService;
import cn.wolfcode.luowowo.search.service.ITravelTemplateService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;

@Service
public class DestinationTemplateServiceImpl implements IDestinationTemplateService {

    @Autowired
    private IDestinationTemplateRepository destinationTemplateRepository;
    @Autowired
    private ISearchService searchService;

    @Override
    public DestinationTemplate queryWithHighlight(IndexSearchQo qo) {
        Page<DestinationTemplate> page = searchService.searchWithHighlight(qo.getIndex(), qo.getTrueType(), DestinationTemplate.class, qo, "name");
        return page.getContent().get(0);
    }

    @Override
    public Page queryWithHighlightMore(IndexSearchQo qo) {
        return searchService.searchWithHighlight(qo.getIndex(), qo.getTrueType(), DestinationTemplate.class, qo, "name","info");
    }

    @Override
    public void save(DestinationTemplate template) {
        destinationTemplateRepository.save(template);
    }
}
